#include<bits/stdc++.h>
#define int long long
#define N 300005
using namespace std;

int n, Q, ans;
int l[N], r[N];

signed main() {
	freopen("study.in", "r", stdin);
	freopen("study.out", "w", stdout);
	
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> Q;
	for(int i = 1; i < n; i++) cin >> l[i] >> r[i];
	while(Q--) {
		int opt;
		cin >> opt;
		if(opt == 1) {
			int p, s, e;
			cin >> p >> s >> e;
			l[p] = s;
			r[p] = e;
		}
		else {
			int a, t, b, h; //a->b
			ans = 0;
			cin >> a >> t >> b >> h;
			if(a <= b) {
				for(int i = a; i < b; i++) {
					if(t < l[i]) t = l[i];
					if(t >= r[i]) {
						ans += t - r[i] + 1;
						t = r[i] - 1;
					}
					t++;
				}
			}
			else {
				for(int i = a - 1; i >= b; i--) {
					if(t < l[i]) t = l[i];
					if(t >= r[i]) {
						ans += t - r[i] + 1;
						t = r[i] - 1;
					}
					t++;
				}
			}
			if(t > h) ans += t - h;
			cout << ans << endl;
		}
	}
	
	
	return 0;
}

/*
5 1
3 5
4 8
2 6
5 10
2 5 3 1 10
*/
